﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MvcEngine.Mvc.StarterSite.Controllers;
using System.Web.Mvc;
using MvcEngine.Mvc.Models.ViewModels;
using MvcEngine.Core;
using MvcEngine.Mvc.Filters;
using MvcEngine.Mvc;
using MvcEngine.Mvc.Controllers;
using MvcEngine.Core.Pagination;
using MvcEngine.Mvc.Extensions;
using MvcEngine.Gallery.Models;
using MvcEngine.Gallery.Managers;
using MvcEngine.Gallery.Components.Extensions;

namespace MvcEngine.Gallery.StarterSite.Controllers
{
    public class GalleryCategoryController : BaseController
    {
        public MvcEngineModel Index(Guid galleryId)
        {
            var categories = GalleryCategoryManager.Current.GetAllByGallery(galleryId);

            IList<GalleryCategoryDetailsViewModel> result = new List<GalleryCategoryDetailsViewModel>();

            foreach (var category in categories)
            {
                var categoryViewModel = new GalleryCategoryDetailsViewModel()
                {
                    Id = category.Id,
                    Slug = category.Slug,
                    Name = category.Name,
                    Visible = category.Visible
                };
                result.Add(categoryViewModel);
            }
            return new MvcEngineModelList<GalleryCategoryDetailsViewModel>() {  List = result, ViewName = "Index" };
        }
    }
}
